import  cv2 as cv
import numpy as np

filename = r'lena.jpg'
img = cv.imread(filename)
cv.imshow('original img',img)

dst_Blur = cv.blur(img,(3,3),0)

cv.imshow('Blur img',dst_Blur)
cv.imwrite('lena_Blur.jpg',dst_Blur)
cv.waitKey()

dst_GaussionBlur = cv.GaussianBlur(img,(3,3),0)

cv.imshow('GaussionBlur img',dst_GaussionBlur)
cv.imwrite('lena_GaussionBlur.jpg',dst_GaussionBlur)
cv.waitKey()

dst_medianBlur = cv.medianBlur(img,3)

cv.imshow('medianBlur img',dst_medianBlur)
cv.imwrite('lena_medianBlur.jpg',dst_medianBlur)
cv.waitKey()

#shape(高度，宽度，通道数)
rows = img.shape[1]
cols = img.shape[0]
channels=img.shape[2]

print(img.shape)
allshowimg = np.zeros((cols,rows*4,channels),np.uint8)
print(allshowimg.shape)

allshowimg[0:cols,0:rows, :] = img[0:cols, 0:rows, :]
allshowimg[0:cols,rows:rows*2, :] = dst_Blur[0:cols, 0:rows, :]
allshowimg[0:cols,rows*2:rows*3, :] = dst_GaussionBlur[0:cols, 0:rows, :]
allshowimg[0:cols,rows*3:rows*4, :] = dst_medianBlur[0:cols, 0:rows, :]

cv.imshow('allshowimg img',allshowimg)
cv.imwrite('lena_allshowimgBlur.jpg',allshowimg)
cv.waitKey()